package com.study.spmongodb.config;

import com.study.spmongodb.interceptor.JwtInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author MI
 * @version 1.0
 * @date 2020/10/14 15:45
 * jwt拦截器
 */
// @Configuration
public class InterceptorConfig implements WebMvcConfigurer {//extends WebMvcConfigurationSupport {

    @Autowired
    JwtInterceptor jwtInterceptor;

  /*  @Override|WebMvcConfigurationSupport 的写法|spring.jackson.date-format 失效|https://blog.csdn.net/hybluck/article/details/105412806
    protected void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器声明拦截对象和拦截的请求
        registry.addInterceptor(jwtInterceptor).addPathPatterns("/user/**").excludePathPatterns("/login");

    }*/

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor).addPathPatterns("/user/**").excludePathPatterns("/login");
    }
}
